package com.bw.controller.order;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bw.entity.order.PiOrderItem;
import com.bw.entity.order.PiOrderLog;
import com.bw.resp.ResponseResult;
import com.bw.service.order.IPiOrderLogService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *  订单日志
 * @author yzz
 * @since 2020-06-20
 */
@RestController
@RequestMapping("/orderlog")
public class PiOrderLogController {
    @Autowired
    private IPiOrderLogService iPiOrderLogService;
    private final Logger logger = LoggerFactory.getLogger(PiOrderItemController.class);
    /**
     * 根据订单id查询对应的订单记录
     * @param id
     * @return
     */
    @PostMapping("getById/{id}")
    public ResponseResult itemlist(@PathVariable("id") Long id ){
        logger.info("订单id查询对应的订单记录开始");
        ResponseResult re=new ResponseResult(false,400,"查询失败");
        try {
            QueryWrapper queryWrapper = new QueryWrapper();
            queryWrapper.eq("orderId",id);
            List<PiOrderLog> list = iPiOrderLogService.list(queryWrapper);
            re.setResult(list);
            re.setMessage("查询成功");
            re.setSuccess(true);
            logger.info("订单id查询对应的订单记录结束");
            return  re;
        } catch (Exception e) {
            logger.error("订单id查询对应的订单记录错误,{}"+e.toString());
            return  re;
        }
    }
}
